import 'package:elevator/model/lift_info.dart';
import 'package:mysql1/src/single_connection.dart';

import 'base_model.dart';

class GroupInfo extends BaseModel{
  ///分组名称
  late String name = "";

  int id;

  List<LiftInfo> liftList = [];

  GroupInfo({this.id = 1,this.name=""});

  @override
  String getTag() {
    return name;
  }

  static GroupInfo build(int id, Results group1list, Map<int, LiftInfo> liftInfoMaps) {
    GroupInfo groupInfo = GroupInfo(id:id,name: "Group$id");
    if(null != group1list){
      for (var row in group1list) {
        if(null != row && row.length>=3){
          int liftAddr = row[1];
          if(liftInfoMaps.containsKey(liftAddr)){
            groupInfo.liftList.add(liftInfoMaps[liftAddr]!);
          }
        }
      }
    }
    return groupInfo;
  }

}